home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / owlbwcc.zip / BWCIMALT.CPP < prev    next >
C/C++ Source or Header  |  1992-02-02  |  5KB  |  111 lines

  1. /**********************************************************************/
  2. /*                  BWCIMALT.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 2/02/92                 */
  4. /*          This program shows how to switch to different             */
  5. /*            routines based on the button pressed using              */
  6. /*              Dynamic Dispatched Virtual Tables, DDVT               */
  7. /*      It also shows how to use pointers to BWCC check boxes         */
  8. /*           to show the ON/OFF status of the check boxes             */
  9. /**********************************************************************/
  10. #include <owl.h>
  11. #include <dialog.h>
  12. #include "bwcc.h"                        // needed for BWCC
  13. #include "bchkbox.h"                     // needed for BWCC checkboxs
  14. #include "BWCIMALT.H"                    // equates for checkboxes
  15.  
  16. class TMyDialog : public TDialog
  17.   {
  18.   public:
  19.     TBCheckBox *pcbRadar12, *pcbConfabulator12;  // pointers to check boxes
  20.  
  21.     TMyDialog(LPSTR lpDialogName)          // constructor calls
  22.       : TDialog(NULL,lpDialogName)         // base class constructor
  23.       {
  24.       BWCCGetVersion();    // activate Borland Windows Custom Controls
  25.  
  26.       pcbRadar12 = new TBCheckBox(this,IDB_RADAR12,NULL);    //links up
  27.       pcbConfabulator12 = new TBCheckBox(this,               //pointers
  28.                      IDB_CONFABULATOR12, //to check boxes
  29.                      NULL);              //That were made
  30.       }                                                      //via the .RC
  31.  
  32.     virtual void HandleRadar12(RTMessage Msg)  // these DDVT toggles
  33.       = [ID_FIRST + IDB_RADAR12];              // activate immediately
  34.     virtual void HandleConfabulator12(RTMessage Msg) // like regular
  35.       = [ID_FIRST + IDB_CONFABULATOR12];             // buttons
  36.  
  37.     virtual void DefChildProc(RTMessage Msg); // default button handler
  38.   };
  39.  
  40. void TMyDialog::HandleRadar12(RTMessage)
  41.   {
  42.   if (pcbRadar12->GetCheck()==BF_CHECKED)           // find out the ON/OFF
  43.     {                                               // status of the checkbox
  44.                             // using a pointer to the
  45.                             // checkbox
  46.     MessageBeep(0);                                 // if we turned it on
  47.     BWCCMessageBox(HWindow,"Radar Unit 12 Activated", // beep and display
  48.                "ACTIVATION!",MB_OK);      // message box
  49.     }
  50.   else                                              // if we turned it off
  51.     {
  52.     MessageBeep(0);                                 // beep and display a
  53.     BWCCMessageBox(HWindow,"Radar Unit 12 OFF",     // different message
  54.                "SHUTDOWN!",MB_OK);
  55.     }
  56.   }
  57.  
  58. void TMyDialog::HandleConfabulator12(RTMessage)     // Same for second
  59.   {                                                 // Item
  60.   if (pcbConfabulator12->GetCheck()==BF_CHECKED)
  61.     {
  62.     MessageBeep(0);
  63.     BWCCMessageBox(HWindow,"Confabulator on Unit 12 Activated",
  64.                "ACTIVATION!",MB_OK);
  65.     }
  66.   else
  67.     {
  68.     MessageBeep(0);
  69.     BWCCMessageBox(HWindow,"Confabulator on Unit 12 OFF",
  70.                "SHUTDOWN!",MB_OK);
  71.     }
  72.   }
  73.  
  74. void TMyDialog::DefChildProc(RTMessage Msg)   // default button handler
  75.   {
  76.   MessageBeep(0);                             // make sound and display
  77.   BWCCMessageBox(HWindow,"Not Implemented",   // a BWCC message box
  78.          "Feature",MB_OK);
  79.   TDialog::DefChildProc(Msg);                 // pass messages along
  80.   }                                           // to base class handler
  81.  
  82. class TDialog1App : public TApplication  // Application Class to contain
  83.   {                                      // the application
  84.   public:
  85.     TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  86.         HANDLE hPrevInstance,            // base class constructor
  87.         LPSTR lpCmdLine, int nCmdShow)
  88.         :TApplication(lpName, hInstance,
  89.                   hPrevInstance,
  90.                   lpCmdLine, nCmdShow) {};
  91.  
  92.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  93.   };
  94.  
  95. void TDialog1App::InitMainWindow() // to initialize a dialog box
  96.   {                                // as the main window
  97.   MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  98.   }
  99.  
  100. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  101.            HANDLE hPrevInstance,          // windows to this program
  102.            LPSTR lpCmdLine , int nCmdShow)
  103.   {
  104.   TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
  105.                hPrevInstance,             // the dialog application
  106.                lpCmdLine,nCmdShow);
  107.   Dialog1.Run();                                  // run it
  108.   return (Dialog1.Status);                        // exit
  109.   }
  110. /**********************************************************************/
  111.